/*
 * @Author: hongbin
 * @Date: 2021-12-08 17:39:08
 * @LastEditors: hongbin
 * @LastEditTime: 2021-12-20 19:01:47
 * @Description: 音乐
 */
const fs = require('fs');
const { ObjectId } = require("mongodb");
const musicCollection = 'music';
const { musicsPath, role: { admin } } = require('../config');

const getSourcePath = (path) => path.replace(/\/\w+\/$/, '/music/');

const getMusic = (req, res) => {
    const file = req.url.replace('\/getMusic\/', '');
    console.log(file);
    res.sendFile(`${musicsPath}${file}`)
}
/**
 * @description: 返回歌曲的基本信息
 */
//TODO 完善逻辑
const getMusicInfo = (req, res) => {
    res.json({
        name: "让风告诉你",
        desc: "原神2021拜年纪同人曲",
        link: `https://api.hongbin.xyz:3002/getMusic/rangfenggaosuni.m4a`,
        cover: "0a35c273e6db10cbb0c20a9703630642.jpeg"
    })
}

module.exports = {
    getMusic, getMusicInfo
}